package com.itheima.maopao;

import java.util.Arrays;

public class Demo01 {
    public static void main(String[] args) {
        int[] arr= {19,82,37,46,55,26};

       /* for (int  j=0;j<arr.length-1;j++) {//比较的轮次
            for (int i = 0; i < arr.length-1-j; i++) {//内部比较的次数
               //arr[i]  arr[i+1]
               if(arr[i]>arr[i+1]){
                   int temp=arr[i];
                   arr[i]=arr[i+1];
                   arr[i+1]=temp;
               }
            }
        }
*/
       //经过多轮次比较
        for (int i = 0; i < arr.length - 1; i++) {
            //每一轮经过多次比较
            for (int j = 0; j < arr.length - 1 - i; j++) {
                //比较并交换
                //arr[j] arr[j+1]
                if(arr[j]>arr[j+1]){
                    int temp=arr[j+1];
                    arr[j+1]=arr[j];
                    arr[j]=temp;
                }
            }


        }


        System.out.println(Arrays.toString(arr));



    }

}
